package com.sevenStar.healthManagement.service.impl;

import com.sevenStar.healthManagement.entity.User;
import com.sevenStar.healthManagement.mapper.UserMapper;
import com.sevenStar.healthManagement.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;

	@Override
	public boolean register(User user) {
		String id = UUID.randomUUID().toString().replaceAll("-", "");
		user.setId(id);
		return userMapper.insertUser(user) > 0;
	}

	@Override
	public User login(User user) {
		return userMapper.selectOne(user);
	}

	@Override
	public boolean queryPhoneOrIdNumber(User user) {
		return userMapper.selectByPhoneOrIdNumber(user) > 0;
	}

	@Override
	public boolean deleteUser(String id) {
		return (userMapper.deleteUserById(id)>0);
	}
}
